package model;

import javax.servlet.http.HttpServletRequest;

/**
 * ModelFactory implements and directs the flow of model invokation of
 * models which implement user and website views.
 *
 * @author Reynaldo Gonzales & Tyler Wood.
 * @version 1.0
 *
 */
public class ModelFactory {

    /**
     * createModel implements direction of which model should be used based on a
     * valid request and model name/type.
     *
     * @param a HttpServletRequest request which hold POST/GET request
     * informtation from a user on the Lithub website.
     * 
     * @param b String modeltype that corresponds to the name of an implemented
     * model.
     *
     * @return invokation of a model.
     *
     */
    public static Model createModel(HttpServletRequest request, String modelType) {
        if (modelType.equals("UserPage")) {
            return new UserPage(request);
        }
        if (modelType.equals("SearchPage")) {
            return new SearchPage(request);
        }
        if (modelType.equals("LoginPage")) {
            return new LoginPage(request);
        }
        if (modelType.equals("Register")) {
            return new Register(request);
        } else {
            return new FrontPage(request);
        }
    }

    /**
     * modelExists returns true providing a model name.
     *
     * @param a Sting model name.
     *
     * @return boolean indicating that the specific model exists.
     *
     */
    public static boolean modelExists(String model) {
        return true;
    }
}
